﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Arcadium.Audio;
using Microsoft.Xna.Framework;

namespace Arcadium.GameEntities.Characters
{
    abstract class EnemyCharacter : UpdatableCharacter
    {
        #region Field

        private bool zombieMode = false;
        private float previousVelocityX;

        #endregion

        #region Initialization

        public EnemyCharacter(World world, int startDirection) : base(world)
        {
            this.Position = world.Map.GetEnemySpawnPoint();
            this.Direction = startDirection;
            SetSpeed(this.Speed / 2f);
        }

        protected void SetSpeed(float speed)
        {
            this.Speed = speed;
            this.previousVelocityX = this.velocity.X =
                speed * this.Direction;
        }

        #endregion

        #region Update

        public override bool Update(GameTime gameTime)
        {
            if (velocity.X == 0)
            {
                previousVelocityX *= -1;
                velocity.X = previousVelocityX;
            }
            bool update = base.Update(gameTime);

            if (update && Health > 0  && false)
            {
                if (!zombieMode)
                {
                    zombieMode = true;
                    SetSpeed(this.Speed * 2f);
                }
                AudioManager.ZombieMode.Play();
                this.Position = World.Map.GetEnemySpawnPoint();
                return false;
            }
            return update;
        }

        #endregion

    }
}
